import React, { Component } from 'react'
import axios from "axios"
class Class extends Component {
  state = {
      arr:[]
  }
  componentDidMount() { // 相当一vue得mountd
        axios.get("/list").then(res=>{
            console.log(res.data);
             this.setState({
                 arr:res.data
             })
        })
  }
  render() {
    console.log(this.props)
    return (
      <div>
          {
              this.state.arr&&this.state.arr.length?this.state.arr.map((item,index)=>{
                return <h4 key={index}>{item.name}</h4>
              })
              :"暂无数据"
          }
         <i>{this.props.send}</i>
      </div>
    )
  }
}

export default Class